Deprecate roots, sampling, and logging per SEP-2577 - #406
Conversation
d8066ae to
6cabe09
Compare
0e694e3 to
460adaf
Compare
26a27ad to
9533204
Compare
0c7a871 to
be41c3c
Compare
|
@koic Happy to push this through or were you thinking of doing the deprecation later? |
|
I'd lean toward doing the deprecation later rather than merging the full behavior change now. This SEP introduces a behavioral switch tied to protocol versioning, and I think that design makes sense because it preserves compatibility with existing protocol versions. However, the 2026-07-28 specification hasn't actually been released yet, and it doesn't appear to have been added to Given that, I'd prefer to wait until the 2026-07-28 release is closer before enabling the deprecation behavior. In the meantime, it might be reasonable to land the advisory annotations on their own. |
|
@koic Sounds good! I can split out the advisory. |
Split the advisory YARD @deprecated annotations out of modelcontextprotocol#406 so the documentation can land ahead of the 2026-07-28 protocol release. Per maintainer feedback, this drops the protocol-version-gated runtime Kernel.warn behavior and the new 2026-07-28 supported protocol version, leaving only the @deprecated notes for the Roots, Sampling, and Logging APIs deprecated by SEP-2577. Refs modelcontextprotocol#390 Co-authored-by: 🦞 Qlaw <noreply@qlaw.quick.shopify.io>
|
Split the advisory annotations out into #429 so they can land independently of the protocol-version behavior change. I'll keep this PR open for the |
## Motivation and Context The MCP specification defines `sampling/createMessage` as a server-to-client request that lets a server ask the client to generate an LLM completion, so the server can leverage the client's model access without its own API keys. The Ruby SDK already supports the server side (sending the request) and, on the client side, the generic server-to-client request infrastructure introduced for elicitation (the standalone GET SSE listening stream and `on_server_request` dispatch). This adds the client-side `sampling/createMessage` handler on top of that infrastructure. ## Changes - Add `MCP::Client#on_sampling`, a thin wrapper that registers a `sampling/createMessage` handler via `transport.on_server_request`, mirroring `on_elicitation`. The handler receives the request params and returns a `CreateMessageResult`-shaped Hash sent back as the JSON-RPC result. - Document client-side sampling in the README, including the `sampling` (and `sampling.tools`) capability declaration and the human-in-the-loop guidance from the specification. ## How Has This Been Tested? - Unit tests for `on_sampling` covering handler registration on the transport and the error raised when the transport does not support server-to-client requests. - An HTTP transport test that dispatches a `sampling/createMessage` server request delivered on the SSE stream and returns a `CreateMessageResult`. ## Deprecation Note SEP-2577 deprecates sampling (along with roots and logging) starting with protocol version `2026-07-28`. The deprecation warnings are added in #406. Sampling remains fully supported under the current `2025-11-25` protocol version and stays available throughout the spec's deprecation window, so the client side is implemented here for parity with the server side and with the Python and TypeScript SDKs. `MCP::Client#on_sampling` carries the same `@deprecated` annotation as the server-side senders annotated in #429, tailored to the receiving side: the handler exists to interoperate with servers that still send sampling requests during the deprecation window. The README section carries the same note. Ref: https://modelcontextprotocol.io/specification/2025-11-25/client/sampling
be41c3c to
9bdcb55
Compare
|
@koic Are we ready for this? |
|
I plan to release MCP Ruby SDK v1.0 tomorrow (#470). I will merge this PR once both Ruby SDK v1.0 and the MCP 2026-07-28 specification have been released. Thank you for your patience. |
|
I've merged #476. I think it would make sense to include this change in v1.2.0 instead. Could you please rebase this PR onto the latest Also, since changelog entries are added at release time, it might be better not to include one here to avoid merge conflicts. |
| }.freeze | ||
|
|
||
| def deprecated_roots_sampling_logging?(protocol_version) | ||
| protocol_version == Configuration::ROOTS_SAMPLING_LOGGING_DEPRECATED_PROTOCOL_VERSION |
There was a problem hiding this comment.
It looks like this should support not only the 2026-07-28 specification, but also future specification versions.
9bdcb55 to
445e609
Compare
445e609 to
126e841
Compare
Warn when Roots, Sampling, or Logging APIs and capabilities are used with MCP protocol version 2026-07-28 or newer. Cover stateful and stateless transports, preserve behavior for older or unavailable protocol versions, and add regression tests for capability shapes, warning call sites, and future versions. Closes modelcontextprotocol#390 Co-authored-by: Qlaw <noreply@qlaw.quick.shopify.io>
126e841 to
3e15286
Compare
TL;DR
Deprecate MCP Roots, Sampling, and Logging when protocol version
2026-07-28or a later protocol version is negotiated or explicitly configured.Context
SEP-2577 deprecates Roots, Sampling, and Logging as of the
2026-07-28protocol version while keeping them fully functional during the deprecation window.Closes #390
Changes
2026-07-28as the deprecation threshold.Testing
ruby -cfor all changed Ruby filesgit diff --check